<?php
/**
 *
 *
 *
 */
class Yz_Form_Element_Checkbox
    extends Yz_Form_Element_Abstract
    implements Yz_Form_Element_Interface
{

    protected $name;
    protected $value = 0;


    /** render
     *
     */
    public function render(Yz_Template_Interface $template)
    {
        $class = $this->getCSSClass();
        $checked = $this->value > 0 ? ' checked="checked"' : "";
        $o = <<<html
            <input type="checkbox" name="{$this->name}" value="1"{$checked} class="{$class}" />\n
html;
        return $o;
    }


    /** parse
     *
     */
    public function parse(Yz_Hash $values)
    {
        $elName = $this->name;
        debug("Element '$elName'");
        $value = $values[$elName];
        $this->value = "1" === $value ? 1 : 0;
        return $this;
    }



}
